package test.h0817;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int[] array = Arrays.stream(s.split(" ")).mapToInt(Integer::parseInt).toArray();

        LinkedList<Integer> stack = new LinkedList<>();

        for (int i = 0; i < array.length; i++) {
            stack.offerLast(array[i]);
            while (true) { //这里之所以用while循环的原因是因为可能新加入的元素会跟前面的元素仍然可以满足定律
                int num = judge(stack);
                //TODO
                if (num==0) break;

                Integer top = stack.removeLast();
                for (int k = 0; k < num; k++) {
                    stack.removeLast();
                }
                stack.offerLast(2 * top);
            }
        }
        StringJoiner joiner = new StringJoiner(" ");
        while (!stack.isEmpty()) {
            joiner.add(stack.removeLast() + "");
        }
        System.out.println(joiner);
    }

    private static int judge(LinkedList<Integer> stack) {
        LinkedList<Integer> list = new LinkedList<>(stack);
        int top = list.removeLast();
        int ans = 0;
        int sum = 0;
        while (!list.isEmpty()) {
            sum += list.removeLast();
            if (top < sum) {
                return 0;
            } else {
                ans++;
                if (top==sum) break;
            }
        }
        //这个是为了保证5 10这种情况，还没等top<sum栈已经为空.
        return top == sum ? ans : 0;
    }
}
